<%-- 
    Document   : unjoin
    Created on : Dec 9, 2011, 12:57:39 AM
    Author     : Owner
--%>

<%@page import="java.sql.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<% if(session.getAttribute("LoggedIn")==null)
       {
    response.sendRedirect("index.html");
    return;
        }

%>
<%
    String circleID = request.getParameter("CIRC");
    String usrID = session.getAttribute("UserID").toString();
    session.setAttribute("CIRC",circleID); //incase it fails and goes back to circlepage
    Connection conn = null;
     try
    {
        conn = new DBClasses.GetConnection().getConnection();
        String sql= "DELETE FROM circlemembership"
                +" WHERE CustomerID = "+usrID+" AND CircleID = "+circleID;
        
        conn.createStatement().execute(sql);
        
    }
    catch(Exception e)
    {
        
        e.printStackTrace();
        response.sendRedirect("CirclePage.jsp");
    }
    finally
    {
        try 
        { 
            conn.commit();
            conn.close();
            
            response.sendRedirect("gohome.jsp"); 
        }
        catch(Exception e) 
        {  
           
            e.printStackTrace();
            response.sendRedirect("gohome.jsp"); 

        }
    }
%>